class BlackDeathHeroInventoryManager extends BlackDeathSocketedInventoryManager
	config(Game);

/**Weapon types:
0 - None
1 - fists
2 - sword
3 - Torch
Expand as neccisary
*/
	
struct Recipe
{
	var class<Inventory> Result;
	var array< Name >  Ingrediants;
};

var array< Recipe > Recipes;

var array < int > KnowRecipes;

reliable client function SetCurrentWeapon(Weapon DesiredWeapon)
{
	if(BlackDeathHeroPawn(Instigator).CanChangeWeapon())
	{
		if(Instigator.IsInState('Attacking'))
		{
			Super.SetCurrentWeapon(DesiredWeapon);
		}
		else
		{
			BlackDeathHeroPawn(Instigator).ToggleAttacking();
		}
	}
}

simulated function Array< int > getKnowRecipes()
{
	return KnowRecipes;
}

simulated function bool Craft(Recipe recp)//Check before useing, can partially remove inventory and then fail
{
	local Name n;
	local inventory inv;
	foreach recp.Ingrediants(n)
	{
		inv = inventorychain;
		while(true)
		{
			if(inv == none)
			{
				return false;
			}
			if(inv.isA(n))
			{
				RemoveFromInventory(inv);
				break;
			}
			inv = inv.inventory;
		}
	}
	inv = CreateInventory(recp.Result);
	return (inv != none);
}

simulated function bool CheckRecipe(Array< inventory > items, out Recipe recp)
{
	local Recipe R;
	local Array<inventory> UsedItems;
	local Inventory inv, used;
	local bool Avalible;
	local int k;
	foreach Recipes(R)
	{
		for(k = 0; k < R.Ingrediants.length; k++)
		{
			useditems[k] = none;
			foreach items(inv)
			{
				if(inv.isA(R.Ingrediants[k]))
				{
					Avalible = true;
					foreach useditems(used)
					{
						if(used == inv)
						{
							Avalible = false;
							break;
						}
					}
					if(Avalible)
					{
						UsedItems[k] = inv;
						break;
					}
				}
			}
			if(UsedItems[k] == none)
				break;
			if((k+1) == R.Ingrediants.length)
			{
				recp = R;
				return true;
			}
		}
	}
	return false;
}

defaultproperties
{
	HolderSocketNums = (2,2,2,2)
}